package com.jf3q.admin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jf3q.admin.service.EduMemberService;
import com.jf3q.common.constant.SysConstant;
import com.jf3q.common.domain.EduMember;
import com.jf3q.common.mapper.EduMemberMapper;
import com.jf3q.common.vo.MemberVo;
import com.jf3q.security.vo.MenuVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

@Service
public class EduMemberServiceImpl extends ServiceImpl<EduMemberMapper, EduMember> implements EduMemberService {
    @Autowired
    EduMemberMapper memberMapper;
    @Override

    public Page<EduMember> getPage(Integer pageNum, MemberVo memberVo) {
        Page<EduMember> page= new Page<>(pageNum, SysConstant.servicePageSize);
        QueryWrapper<EduMember> queryWrapper= new QueryWrapper();
        queryWrapper.orderByDesc("edu_modified");
        queryWrapper.eq("is_disabled",0);

        if (!ObjectUtils.isEmpty(memberVo.getNickname())) {
            queryWrapper.like("nickname",memberVo.getNickname());
        }
        if (!ObjectUtils.isEmpty(memberVo.getMobile())) {
            queryWrapper.eq("mobile",memberVo.getMobile());
        }

        Page<EduMember> iPage = baseMapper.selectPage(page, queryWrapper);
        return iPage;
    }


}
